﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.DataSourcesRaster;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.SystemUI;

namespace WindowsFormsApp2
{
    class Class1
    {
        public void AddShapeFile2(AxMapControl mapcontrol1, string path, string filename)
        {
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(path, 0);
            IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(filename);
            IFeatureLayer pFeatureLayer = new FeatureLayer();

            pFeatureLayer.FeatureClass = pFeatureClass;
            pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName;
            mapcontrol1.Map.AddLayer(pFeatureLayer);
            mapcontrol1.ActiveView.Refresh();
        }
    }
}
